package com.sbpm.crmbpm.client.deprecforms;


import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.form.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @deprecated
 */
public abstract class CurrencyControllerForm extends ProcessForm
{

    private TextField name;
    private TextField sum;
    private TextField receiver;
    private CheckBox approvedByVerifier;
    private CheckBox approvedByCC;
    private Long id;
    private Long processInstanceId;

    public CurrencyControllerForm()
    {
        init( "Currency Control" );
    }

    @Override
    public Map< String, Object > getData()
    {
        Map< String, Object > map = new HashMap<>();
        map.put( "approved", approvedByCC.getValue().toString() );
        return map;
    }

    @Override
    public void setData( Map< String, Object > data )
    {
/*
        name.setValue( ( String )data.get( "Name" ) );
        sum.setValue( ( String )data.get( "Sum" ) );
        receiver.setValue( ( String )data.get( "Receiver" ) );
*/
        approvedByVerifier.setValue( Boolean.TRUE.equals( data.get( "approvedByVerifier" ) ) );
        name.setValue( ( String )data.get( "transfer.name" ) );
        sum.setValue( ( String )data.get( "transfer.sum" ) );
        receiver.setValue( ( String )data.get( "transfer.receiver" ) );
        id = ( Long )data.get( "transfer.id" );
        processInstanceId = ( Long )data.get( "transfer.processInstanceId" );

    }

    public void createForm( FramedPanel panel )
    {
        FieldSet fieldSet = new FieldSet();
        fieldSet.setHeadingText( "Transfer information" );
        fieldSet.setCollapsible( false );
        panel.add( fieldSet );

        VerticalLayoutContainer p = new VerticalLayoutContainer();
        fieldSet.add( p );

        name = new TextField();
        name.setReadOnly( true );
        name.setAllowBlank( false );
        name.setReadOnly( true );
        p.add( new FieldLabel( name, "Name" ), new VerticalLayoutContainer.VerticalLayoutData( 1, -1 ) );

        sum = new TextField();
        sum.setReadOnly( true );
        sum.setAllowBlank( false );
        sum.setReadOnly( true );
        p.add( new FieldLabel( sum, "Sum" ), new VerticalLayoutContainer.VerticalLayoutData( 1, -1 ) );

        receiver = new TextField();
        receiver.setReadOnly( true );
        receiver.setAllowBlank( false );
        receiver.setReadOnly( true );
        p.add( new FieldLabel( receiver, "Receiver" ), new VerticalLayoutContainer.VerticalLayoutData( 1, -1 ) );

        approvedByVerifier = new CheckBox(  );
        approvedByVerifier.setBoxLabel( "Approved By Verifier" );
        approvedByVerifier.setReadOnly( true );
        approvedByVerifier.setEnabled( false );
        p.add( approvedByVerifier, new VerticalLayoutContainer.VerticalLayoutData( 1, -1 ) );

        approvedByCC = new CheckBox(  );
        approvedByCC.setBoxLabel( "Approved By Currency Control" );
        p.add( approvedByCC, new VerticalLayoutContainer.VerticalLayoutData( 1, -1 ) );



    }

}
